import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_kit_plus/flutter_kit.dart';

bool turn_on = true;
bool mic_on = false;

int rgbIndex = 0;
String ledNum = '200'; // 存储输入的值

String rgbIndexKey = 'rgbIndexKey';
String ledNumKey = 'ledNumKey';

///主题背景颜色
const Color Color_red = Color(0xFFCC2D1F);
const Color Color_mid = Color(0xFF4088B0);
const Color Color_theme = Color(0xFF00A1D5);
const Color Color_border = Colors.black;
const Color Color_bg_view = Colors.white;
const Color Color_disEnable = Color(0xFF8F989C);
const Color Color_purple = Color(0xFF85519C);
const Color Color_green = Color(0xFF6CB930);
const Color Color_thumbColor = Color(0xFF292F74);
const Color Color_yellow = Color(0xFFE29D4F);
// const fontNormal = TextStyle(fontWeight: FontWeight.w600, color: Colors.black);
// const font20 = TextStyle(color: Colors.black, fontWeight: FontWeight.w600, fontSize: 20);
// const font30 = TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 30);
const BankFont = 'BankFont';

final fontNormal = font(null);
final font14 = font(14);
final font20 = font(20);
final font30 = font(30);
final font40 = font(40);

TextStyle font(double? font) {
  return TextStyle(
      color: Colors.black, fontFamily: BankFont, fontWeight: FontWeight.bold, height: 1.0, fontSize: font ?? 16);
}

BoxDecoration boxDecoration(double radius) {
  return BoxDecoration(borderRadius: BorderRadius.circular(radius), border: Border.all(color: Colors.black, width: 1));
}

BoxDecoration boxDecorationWithColor(double radius, Color color) {
  return BoxDecoration(
      borderRadius: BorderRadius.circular(radius), color: color, border: Border.all(color: Colors.black, width: 1));
}

Widget backButtom(BuildContext context) {
  return myIconButton(iconName: assets.home, width: 40, height: 40, onTap: () => Navigator.pop(context));
}

const LinearGradient localGradient = LinearGradient(
  begin: Alignment.topLeft, // 渐变的开始位置，左边
  end: Alignment.bottomRight, // 渐变的结束位置，右边
  colors: [
    Colors.black, // 起始颜色
    Colors.purple, // 结束颜色
  ],
);

// // 保存字符串
// Future<void> saveString(String key, String value) async {
//   final prefs = await SharedPreferences.getInstance();
//   await prefs.setString(key, value);
// }

// // 获取字符串
// Future<String?> getString(String key) async {
//   final prefs = await SharedPreferences.getInstance();
//   return prefs.getString(key);
// }

class GlobalConfig {
  static double scaleH = 0.0;
}

class assets {
  static const String _basePath = 'assets/images/';

  static String getImagePath(String imageName) {
    return '$_basePath$imageName.png';
  }

  // 定义具体的图片资源
  static const String B1 = '${_basePath}B1.png';
  static const String B2 = '${_basePath}B2.png';
  static const String B3 = '${_basePath}B3.png';
  static const String B4 = '${_basePath}B4.png';
  static const String B5 = '${_basePath}B5.png';
  static const String B6 = '${_basePath}B6.png';
  static const String L1 = '${_basePath}L1.png';
  static const String L2 = '${_basePath}L2.png';
  static const String L3 = '${_basePath}L3.png';
  static const String L4 = '${_basePath}L4.png';
  static const String L5 = '${_basePath}L5.png';
  static const String L6 = '${_basePath}L6.png';

//首页
  static const String btn_eq_select = '${_basePath}btn_eq_select.png';
  static const String btn_eq = '${_basePath}btn_eq.png';
  static const String btn_in_select = '${_basePath}btn_in_select.png';
  static const String btn_in = '${_basePath}btn_in.png';
  static const String btn_out_select = '${_basePath}btn_out_select.png';
  static const String btn_out = '${_basePath}btn_out.png';
  static const String btn_time = '${_basePath}btn_time.png';
  static const String btn_time_select = '${_basePath}btn_time_select.png';
  static const String btn_xo_select = '${_basePath}btn_xo_select.png';
  static const String btn_xo = '${_basePath}btn_xo.png';
  static const String massive = '${_basePath}massive.png';
  static const String mic_off = '${_basePath}mic_off.png';
  static const String mic_on = '${_basePath}mic_on.png';
  static const String more = '${_basePath}more.png';
  static const String next = '${_basePath}next.png';
  static const String offline_bg = '${_basePath}offline_bg.png';
  static const String online_bg = '${_basePath}online_bg.png';
  static const String pause = '${_basePath}pause.png';
  static const String play = '${_basePath}play.png';
  static const String previous = '${_basePath}previous.png';
  static const String home = '${_basePath}home.png';
  static const String mic_on2 = '${_basePath}mic_on2.png';
  static const String mic_off2 = '${_basePath}mic_off2.png';

  //喇叭
  static const String soud_b_off = '${_basePath}soud_b_off.png';
  static const String soud_b_on = '${_basePath}soud_b_on.png';
  static const String soud_f_l_off = '${_basePath}soud_f_l_off.png';
  static const String soud_f_l_on = '${_basePath}soud_f_l_on.png';
  static const String soud_f_r_off = '${_basePath}soud_f_r_off.png';
  static const String soud_f_r_on = '${_basePath}soud_f_r_on.png';
  static const String soud_m_l_off = '${_basePath}soud_m_l_off.png';
  static const String soud_m_l_on = '${_basePath}soud_m_l_on.png';
  static const String soud_m_r_off = '${_basePath}soud_m_r_off.png';
  static const String soud_m_r_on = '${_basePath}soud_m_r_on.png';
  static const String car = '${_basePath}car.png';
  static const String arrow_left = '${_basePath}arrow_left.png';
  static const String arrow_right = '${_basePath}arrow_right.png';
  static const String arrow = '${_basePath}arrow.png';
  static const String arrow2 = '${_basePath}arrow2.png';
  static const String add = '${_basePath}add.png';
  static const String sub = '${_basePath}sub.png';
  static const String unit = '${_basePath}unit.png';
  static const String unit_select = '${_basePath}unit_select.png';
  static const String bluetooth = '${_basePath}bluetooth.png';

//
  static const String bg = '${_basePath}bg.png';
  static const String ble_off = '${_basePath}ble_off.png';
  static const String ble_on = '${_basePath}ble_on.png';
  static const String icon = '${_basePath}icon.png';
  static const String logo = '${_basePath}logo.png';
  static const String arrow_long = '${_basePath}arrow_long.png';

  ///读取本地文件
  static Future<Uint8List?> readBinFile(String fileName) async {
    try {
      // 读取 bin 文件
      ByteData data = await rootBundle.load('assets/$fileName');

      // 将 ByteData 转换为 Uint8List 并返回
      return data.buffer.asUint8List();
    } catch (e) {
      print('Error reading bin file: $e');
      return null;
    }
  }
}
